package com.probiz.estoresf.customer.web.action;


import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.validation.BindException;

import com.probiz.estore.common.model.customer.Favorite;
import com.probiz.estore.core.controller.GenericCustomerFrontController;
import com.probiz.estore.core.search.SearchCriteria;
import com.probiz.estore.customer.service.FavoriteManager;
import com.probiz.estore.webapp.util.RequestContext;

public class FavoriteFrontController extends GenericCustomerFrontController<Favorite> {
	
    private FavoriteManager 	favoriteManager 	= null;
    
	public void setFavoriteManager(FavoriteManager favoriteManager) {
		this.favoriteManager = favoriteManager;
	}

	@Override
	protected void initController() throws Exception {
		mgr = favoriteManager;
	}
	
	@Override
	protected String getEntityName(Favorite entity) {
		if (entity != null) {
			return entity.getFavoriteName();
		}
		return null;
	}

	@Override
	protected Map<Integer, Map<String, Object>> getMultiSaveModel(
			HttpServletRequest request) {
		return null;
	}

	@Override
	protected void preSave(HttpServletRequest request, Favorite entity,
			BindException errors) {
		
	}

	public SearchCriteria createSearchCriteria(HttpServletRequest request) {
		SearchCriteria searchCriteria = this.createSearchCriteria(request, Favorite.FilterHqlName.FOR_CUSTOMER);
		searchCriteria.addParamValue(RequestContext.getCurrentUserId());
		return searchCriteria;
	}

}
